<!DOCTYPE html>
<html lang="en">

<head>
       
    <meta charset="UTF-8">
       
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
       
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
        * {
            padding: 0;
            margin: 0;
        }

        .box {
            width: 500px;
            height: 300px;
            margin: 50px auto;
            text-align: center;
            line-height: 300px;
            border: 1px solid red;
        }

        span {
            border: 1px solid green;
        }
    </style>
</head>

<body>
    <div class="box">
        <span>居中</span>
    </div>
</body>

</html>